package com.lemon.exam.controller;

import com.lemon.exam.common.annotation.NestedParam;
import com.lemon.exam.common.annotation.Web;
import com.lemon.exam.common.web.Param;
import com.lemon.exam.entity.po.LoggingPO;
import com.lemon.exam.service.ILoggingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.data.domain.Page;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

/**
 * 日志 控制器
 *
 * @author Lemon
 * @since 2025/04/20 22:06:24
 */
@RestController
@RequestMapping("logging")
@Tag(name = "日志管理", description = "日志 API")
@Web(childUri = "logging", childComponent = "system/Logging.vue")
public class LoggingController {
    @Resource
    private ILoggingService loggingService;

    /**
     * 查询
     *
     * @param id
     * @return
     */
    @GetMapping("findById/{id}")
    @Operation(summary = "查询", description = "根据主键查询")
    public Mono<LoggingPO> findById(@PathVariable("id") Long id) {
        return loggingService.findById(id);
    }

    /**
     * 分页
     *
     * @param param
     * @return
     */
    @GetMapping("page")
    @Operation(summary = "分页")
    public Mono<Page<LoggingPO>> page(@NestedParam Param param) {
        return loggingService.page(param);
    }

    /**
     * 导出
     *
     * @param param
     */
    @PostMapping("export")
    @Operation(summary = "导出")
    public Mono<Void> export(@RequestBody Param param, ServerHttpResponse response) {
        return loggingService.export(param, response);
    }
}
